package routing

import (
	"day01/project_learning/chapter_05/controller"
	"github.com/gin-gonic/gin"
	"net/http"
)

func TestRouting(r *gin.Engine) {
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "pong",
		})
	})

	r.GET("/index", func(c *gin.Context) {
		c.HTML(http.StatusOK, "gin.html", gin.H{
			"title": "Main website",
		})
	})

	r.GET("/posts/index", func(c *gin.Context) {
		c.HTML(http.StatusOK, "posts/index.tmpl", gin.H{
			"title": "Posts",
		})
	})
	r.GET("/users/index", func(c *gin.Context) {
		c.HTML(http.StatusOK, "users/index.tmpl", gin.H{
			"title": "Users",
		})
	})
	r.GET("/someGet", controller.GetUser)
	r.GET("/mysql", controller.InsertUser)
}
